package com.wuyan.locationdog.adapter

import android.graphics.Color
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import androidx.annotation.LayoutRes
import com.arcsoft.commonbase.bean.DeviceShareBeanContent
import com.arcsoft.commonbase.ext.gone
import com.arcsoft.commonbase.ext.invisible
import com.arcsoft.commonbase.ext.loadImageCircle
import com.arcsoft.commonbase.ext.visible
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.mcxtzhang.swipemenulib.SwipeMenuLayout
import com.wuyan.locationdog.R
import leifu.shapelibrary.ShapeView


class SharePersonListAdapter(@LayoutRes layoutResId: Int, data: MutableList<DeviceShareBeanContent>?) :
    BaseQuickAdapter<DeviceShareBeanContent, BaseViewHolder>(layoutResId, data) {

    var showStatus = true

    override fun convert(holder: BaseViewHolder, item: DeviceShareBeanContent) {
        holder.apply {
            val shapeView = getView<ShapeView>(R.id.shareStatus)
            val swipeMenuLayout = getView<SwipeMenuLayout>(R.id.swipeMenuLayout)

            if (!showStatus) {
                shapeView.invisible()
                getView<TextView>(R.id.createTime).invisible()
                swipeMenuLayout.isSwipeEnable = false
                if (item.isSelect) {
                    getView<View>(R.id.ivCheck).visible()
                } else {
                    getView<View>(R.id.ivCheck).gone()
                }
            }
            if (item.shareStatus == 1) {
                shapeView.setText("已接受")
                shapeView.setTextColor(Color.parseColor("#6E4DF3"))
                shapeView.setShapeSolidColor(Color.parseColor("#1A1259FF"))
                    .setUseShape()
            } else {
                shapeView.setText("等待接受")
                shapeView.setTextColor(Color.parseColor("#FF6430"))
                shapeView.setShapeSolidColor(Color.parseColor("#1AFF6430"))
                    .setUseShape()
            }

            getView<TextView>(R.id.nickName).text = item.nickName
            getView<TextView>(R.id.userPhone).text = "手机号：" + item.userPhone
            getView<TextView>(R.id.createTime).text = item.createTime
            if (item.fileUrl.isNullOrEmpty()) {
                getView<ImageView>(R.id.ivHead).loadImageCircle(item.userAvatarUrl)
            } else {
                getView<ImageView>(R.id.ivHead).loadImageCircle(item.fileUrl)
            }
        }
    }
}


